<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style type="text/css">
        .container {
            background-color: #fff;
            border: 1px solid #e4e4e4;
            border-radius: 5px;
            height: 500px;
            width: 500px;
            border: 3px dotted #eee;
            margin: 0 auto;
            margin-top: 40px;
            padding: 40px;
        }
        ul {
            margin-top: 20px;
        }
        .folder {
            height: 26px;
            width: 26px;
            background: url(./1.png) -594px -862px no-repeat;
            cursor: pointer;
        }
        .file {
            height: 26px;
            width: 26px;
            background: url(./1.png)  -594px -68px no-repeat;
            cursor: pointer;
        }
        li {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            display: -webkit-flex;
            margin-top: 10px;
            border-bottom: 1px solid #f2f6fd;
            padding-bottom: 10px;
        }
        li a, li span {
            text-decoration: none;
            font-size: 12px;
            line-height: 26px;
            color: black;
            margin-left: 20px;
            font-family: "Microsoft YaHei";
        }
        li span {
            /* margin-left: 50px; */
            width: 150px;
            text-align: center;
        }
        li a {
            width: 50px;
            text-align: center;
        }
        li .del {
            margin-right: 0px!important;
        }
        .title {
            display: flex;
            /* display: -webkit-flex; */
            font-size: 12px;
            /* justify-content: space-around; */
            margin-left: 60px;
        }
        
    </style>
</head>
<body>
    <div class="container">
        <div class="title">
            <span>类型</span>
            <span style="margin-left: 40px;">文件名</span>
            <span style="margin-left: 80px;">大小</span>
            <span style="margin-left: 100px;">时间</span>
            <span style="margin-left: 73px;">操作</span>
        </div>
        <ul>
        </ul> 
    </div>
</body>
<script>
    ulNode=document.querySelector("ul");
    fetch("http://192.168.174.166:3000/getlist")
        .then(res=>res.json())
        .then(data=>{
            for(let i=0;i<data.length;i++){
                let liNode=document.createElement("li");
                
                data[i].fileType=="folder"?
                liNode.innerHTML=`
                    <div class="folder"></div>
                    <a href="">${data[i]["fileName"]}</a>
                    <span>${data[i]["fileSize"]}</span>
                    <span>${data[i]["fileTime"]}</span>
                    <a href="" class="del" id="dlerer">删除</a>
                `:
                liNode.innerHTML=`
                    <div class="file"></div>
                    <a href="">${data[i]["fileName"]}</a>
                    <span>${data[i]["fileSize"]}</span>
                    <span>${data[i]["fileTime"]}</span>
                    <a href="" class="del" id="dlerer">删除</a>
                `
                // if(data[i].fileType=="folder"){
                //     liNode.innerHTML=`
                //         <div class="folder"></div>
                //         <a href="">${data[i]["fileName"]}</a>
                //         <span>${data[i]["fileSize"]}</span>
                //         <span>${data[i]["fileTime"]}</span>
                //         <a href="" class="del" id="dlerer">删除</a>
                //     `
                // }else{
                //     liNode.innerHTML=`
                //         <div class="file"></div>
                //         <a href="">${data[i]["fileName"]}</a>
                //         <span>${data[i]["fileSize"]}</span>
                //         <span>${data[i]["fileTime"]}</span>
                //         <a href="" class="del" id="dlerer">删除</a>
                //     `
                // }
                ulNode.appendChild(liNode)
            }
        })
</script>
</html>